Skip to content

Conversation

@micheleriva
Copy link
Contributor

This PR supersedes #7971 and integrates the new Orama components, powered by the new OramaCore backend.

Description

New components - React-based to replace the old WebComponents-based ones. New backend (OramaCore instead of old Orama Cloud), all hosted and maintained on https://app.orama.com. Credentials have been shared privately with the repository maintainers on Slack.

Validation

Tested locally and on remote demo environment.

Related Issues

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

g-francesca and others added 30 commits July 9, 2025 11:54
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
@g-francesca
Copy link

@g-francesca Could you please:

  1. Resolve the Playwright issues
  2. Resolve any conflicts (Maybe merging your commits will help with that, 110 is quite a lot 😅)

🙂​ Sure, I'll manage this today @avivkeller.
About the Playwright tests:
I noticed they’re currently failing in CI because the Orama env vars (used to initialize the client) aren’t defined during the test step. Since we made the search button disabled whenever these variables are missing, the tests pass locally, but fail in GitHub Actions, as the button can’t be clicked.

Before I update the workflow to include them, could you confirm whether the variables below are already set as secrets? And if there's any distinction between those used in prod and preview environments that I should take into account?

Would the following update to the test step look correct to you?

      - name: Run Playwright tests
        working-directory: apps/site
        run: node --run playwright
        env:
          PLAYWRIGHT_BASE_URL: ${{ needs.get-vercel-preview.outputs.url }}
          NEXT_PUBLIC_NEW_ORAMA_PROJECT_ID: ${{ github.event_name == 'push' && secrets.NEXT_PUBLIC_NEW_ORAMA_PRODUCTION_PROJECT_ID || secrets.NEXT_PUBLIC_NEW_ORAMA_PROJECT_ID }}
          NEXT_PUBLIC_NEW_ORAMA_API_KEY: ${{ github.event_name == 'push' && secrets.NEXT_PUBLIC_NEW_ORAMA_PRODUCTION_API_KEY || secrets.NEXT_PUBLIC_NEW_ORAMA_API_KEY }}

Thank you!

@ovflowd
Copy link
Member

ovflowd commented Oct 23, 2025

@avivkeller would the GHA snippet above be OK?

@avivkeller
Copy link
Member

avivkeller commented Oct 23, 2025

(Forget my deleted comment above)

No, the snippet does not look good to me. Playwright should run without secrets. We could just remove the Orama tests, and accept that this is a third-party provider not subject to our tests.

@avivkeller
Copy link
Member

avivkeller commented Oct 23, 2025

The "Sync Orama Cloud" test is an expected failure given the changes, but can someone confirm that a local call of that script works with the secrets defined?

If not, I can make a temporary branch to test it.

@g-francesca
Copy link

(Forget my deleted comment above)

No, the snippet does not look good to me. Playwright should run without secrets. We could just remove the Orama tests, and accept that this is a third-party provider not subject to our tests.

Makes sense for me, I can remove the Orama tests

const hasInteractions = !!interactions?.length;

useEffect(() => {
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add a cleanup function of the effect to cancel the setTimeout during component unmount.

const displaySearch =
!isMobileScreen || (isMobileScreen && searchbox.mode === 'search');

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please use our existing useMediaQuery hook here? https://github.com/nodejs/nodejs.org/blob/main/apps/site/hooks/react-client/useMediaQuery.ts instead of this isMobileScreen state

import { Search } from './Search';
import { SlidingChatPanel } from './SlidingChatPanel';

const InnerSearchboxModal: FC<PropsWithChildren<{ onClose: () => void }>> = ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component should reside in another file. Policy here is one component per file :)

const orama = useOrama();
const t = useTranslations();

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of reusability and maintainability could you make a dedicated hook for this? Or use an existing Radix component that could do this? I feel I've mentioned this before?

apiKey: ORAMA_CLOUD_READ_API_KEY,
});
}
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to return null. Make the context be OramaCloud | undefined, createContext by default supports "undefiend", so you only need one return statement.


export const OramaProvider = ({ children }: { children: React.ReactNode }) => {
const instance = useMemo(() => {
if (ORAMA_CLOUD_PROJECT_ID && ORAMA_CLOUD_READ_API_KEY) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these constants are defined statically and won't change during runtime, wouldn't it make sense to create the instance outside of the provider? Does it need to be a react provider? Is it because we want to ensure this is client-side only?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add 'use client';, React Providers are client-side only and we rather be explicit when something is client-side only.


export const useSearchbox = (): SearchboxContextType => {
const context = useContext(SearchboxContext);
if (!context) {
Copy link
Member

@ovflowd ovflowd Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to throw an Error explicitly. It will throw an error for whoever is consuming this anyways.

const searchDispatch = useSearchDispatch();

const clearAll = useCallback(() => {
searchDispatch({ type: 'SET_SEARCH_TERM', payload: { searchTerm: '' } });
Copy link
Member

@ovflowd ovflowd Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you make this an entry on your reducer named CLEAR_ALL?

Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're almost there. I've left a final set of comments. After this we're good to go!

@g-francesca
Copy link

We're almost there. I've left a final set of comments. After this we're good to go!

Hey @ovflowd, thank you for this last review! I'll try to manage everything by tomorrow. I'll keep you posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants